import Cookies from 'js-cookie'
import { Message } from 'element-ui'

export default function({ route, next, store, redirect }) {
  console.log('我先执行了兄弟')
  // return (redirect = '/login')
  if (Cookies.get('token') == null) {
    return redirect('/login/login')
  } else {
    let token = Cookies.get('token')
    // let token = 3
    console.log('权限号码为' + token)
    if (token == 2) {
      if (route.path === '/workspace') {
        return (
          Message.error('登录失败！您没有登陆此页面的权限'), redirect('/home')
        )
      } else {
        // return redirect(route.path)
      }
    }
  }
  // let token=3;
  // let token = Cookie.get(token)

  // if (!store.state.authUser) {
  //   console.log('通过验证')
  //   return redirect('/home')
  // }
}
